import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:moose_app/ui/values/values.dart';

class ATHFoodItem extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.all(Radius.circular(kSize8)),
      child: Container(
        decoration: BoxDecoration(color: Colors.white, boxShadow: [kBoxShadow]),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [_buildFoodImage(), _buildFoodBottom()],
        ),
      ),
    );
  }

  Widget _buildFoodBottom() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: kSize16, vertical: kSize20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            margin: EdgeInsets.only(top: kSize10),
            child: Text(
              "油焖大虾",
              style:
                  TextStyle(fontSize: kFontSize30, fontWeight: FontWeight.bold),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: kSize10),
            child: Row(
              children: [
                Text(
                  "4.7 分",
                  style: TextStyle(
                      color: kColorFF6200,
                      fontSize: kFontSize24,
                      fontWeight: FontWeight.bold),
                ),
                Container(
                  margin: EdgeInsets.only(left: kSize8),
                  child: Text(
                    "味道真的不错",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        color: kColor99,
                        fontSize: kFontSize24,
                        fontWeight: FontWeight.bold),
                  ),
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: kSize10),
            child: Row(
              children: [
                _buildFoodDiscountTag(),
                _buildFoodDiscountTag(),
                _buildFoodDiscountTag(),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: kSize30),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text(
                      "人均¥19",
                      style: TextStyle(color: kColor66),
                    ),
                    Text(
                      "｜",
                      style: TextStyle(color: kColor66),
                    ),
                    Text(
                      "月售 9999",
                      style: TextStyle(color: kColor66),
                    )
                  ],
                ),
                Icon(
                  Icons.more_horiz,
                  color: kColorDDDEDF,
                )
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildFoodImage() {
    return Container(
      child: Stack(
        children: [
          Positioned(
              child: CachedNetworkImage(
            imageUrl:
                "https://img.meituan.net/msmerchant/e631c7f4d08593d34c6318088fde7e9a1896285.png%40280w_212h_1e_1c_1l%7Cwatermark%3D0",
          )),
          Positioned(
              bottom: 0,
              left: 0,
              child: Container(
                padding:
                    EdgeInsets.symmetric(vertical: kSize2, horizontal: kSize4),
                margin: EdgeInsets.all(kSize16),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(kSize10)),
                    color: kColor99.withOpacity(.5)),
                child: Text(
                  "外卖 · 2 分钟送达",
                  style: TextStyle(color: Colors.white, fontSize: kFontSize20),
                ),
              ))
        ],
      ),
    );
  }

  Container _buildFoodDiscountTag() {
    return Container(
        padding: EdgeInsets.symmetric(vertical: kSize2, horizontal: kSize6),
        margin: EdgeInsets.symmetric(horizontal: kSize8),
        decoration: BoxDecoration(
            color: kColorFFE9E1,
            borderRadius: BorderRadius.all(Radius.circular(kSize8))),
        child: Text(
          "2减0.5",
          style: TextStyle(fontSize: kFontSize20, color: kColorFF5000),
        ));
  }
}
